package com.zw.yzk.kabu.view.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * Created by wei on 2016/6/21.
 */
public class MyScrollView extends ScrollView {

    private ScrollListener scrollListener;

    public MyScrollView(Context context) {
        this(context, null);
    }

    public MyScrollView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public MyScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if (scrollListener != null) {
            scrollListener.onScroll(t);
        }
    }

    public void setOnScrollListener(ScrollListener listener) {
        this.scrollListener = listener;
    }

    public interface ScrollListener {
        void onScroll(int dy);
    }
}
